

def hello():
    print('hello world!')


hello()
print('\n')


def t(s, x, h):
    return (s + x) * h / 2


s = 1
x = 2
h = 2
print(t(s, x, h))
print('\n')


def c(w, b):
    return w*b


print(c(1, 2))
print('\n')


def printme(str):
    print(str)
    return


printme('我要调用用户自定义函数！')


def name(name):
    return name


def age(age):
    return age


def User():
    print(name('liwenwen'), age(18))


User()


def ChangeInt(a):
    a = 10
    print(a)


b = 2
b = 3
ChangeInt(b)
print(b)  # 结果是 2


def changeme(mylist):
    "修改传入的列表"
    mylist.append([1, 2, 3, 4])
    print("函数内取值: ", mylist)
    return


# 调用changeme函数
mylist = [10, 20, 30]
changeme(mylist)
print("函数外取值: ", mylist)


def printme(str):
    "打印任何传入的字符串"
    print(str)
    return


# 调用 printme 函数，不加参数会报错
printme()


def printme(str):
    "打印任何传入的字符串"
    print(str)
    return


# 调用printme函数
printme(str="菜鸟教程")


def printinfo(name, age=35):
    "打印任何传入的字符串"
    print("名字: ", name)
    print("年龄: ", age)
    return


# 调用printinfo函数
printinfo(age=50, name="runoob")
print("------------------------")
printinfo(name="runoob")


def printinfo(arg1, *vartuple):
    "打印任何传入的参数"
    print("输出: ")
    print(arg1)
    print(vartuple)


# 调用printinfo 函数
printinfo(70, 60, 50)


def printinfo(arg1, *vartuple):
    "打印任何传入的参数"
    print("输出: ")
    print(arg1)
    *vartuple

    return


# 调用printinfo 函数
printinfo(10)
printinfo(70, 60, 50)


def introduce():
    name = "小明"  # 局部变量
    print("我的名字叫", name)  # 函数内部使用局部变量


introduce()  # 调用函数
# print("我的名字叫%s"%name)#函数外部不能使用局部变量


def jieceng(n):
    if n == 1:
        return 1
    return n*jieceng(n-1)


jieceng(5)
